package com.tonyodev.fetch2;

import com.tonyodev.fetch2.database.DownloadInfo;

import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Set;

/**
 * An immutable object which contains a current snapshot of all the information
 * about a specific download group managed by Fetch.
 *
 * @since 2021-06-17
 */
public interface FetchGroup {
    /**
     * The group id.
     *
     * @return id
     */
    int getId();

    /**
     * The Fetch namespace this group belongs to.
     *
     * @return namespace
     */
    @NotNull
    String getNamespace();

    /**
     * All downloads belonging to this group.
     *
     * @return DownloadInfoList
     */
    @NotNull
    List<DownloadInfo> getDownloads();

    /**
     * All queued downloads belonging to this group.
     *
     * @return DownloadInfo
     */
    @NotNull
    List<DownloadInfo> getQueuedDownloads();

    /**
     * All added downloads belonging to this group.
     *
     * @return DownloadInfo
     */
    @NotNull
    List<DownloadInfo> getAddedDownloads();

    /**
     * All paused downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getPausedDownloads();

    /**
     * All downloading downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getDownloadingDownloads();

    /**
     * All completed downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getCompletedDownloads();

    /**
     * All cancelled downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getCancelledDownloads();

    /**
     * All failed downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getFailedDownloads();

    /**
     * All deleted downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getDeletedDownloads();

    /**
     * All removed downloads belonging to this group.
     *
     * @return downloads
     */
    @NotNull
    List<DownloadInfo> getRemovedDownloads();

    /**
     * The groups downloading progress. -1 if the group progress is indeterminate.
     *
     * @return downloads
     */
    int getGroupDownloadProgress();

    /**
     * The set of FetchObservers attached to this FetchGroup.
     *
     * @return downloads
     */
    @NotNull
    Set<List<DownloadInfo>> getObservers();

    /**
     * Adds FetchGroupObservers that will be notified when the downloads in this group
     * has been updated or changed.  FetchGroupObservers are not lifecycle aware.
     *
     * @param fetchGroupObservers the fetch group observers.
     */
    void addFetchGroupObservers(@NotNull FetchGroupObserver... fetchGroupObservers);

    /**
     * Removes FetchGroupObservers attached to this fetch group.
     *
     * @param fetchGroupObservers to be removed.
     */
    void removeFetchGroupObservers(@NotNull FetchGroupObserver... fetchGroupObservers);
}
